package com.xbongbong.paas.model;

import com.xbongbong.paas.domain.entity.PaasProcessNodeTaskEntity;
import com.xbongbong.paas.domain.entity.ext.PaasProcessNodeTaskEntityExt;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.wrap.IModel;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * PAAS 流程设计类
 *
 * @author wufeng
 * @time 2018-8-8 9:47
 */
public interface PaasProcessNodeTaskModel extends IModel<PaasProcessNodeTaskEntity> {


    /**
     * 批量增加任务
     *
     * @param list
     */
    void insertBatch(List<PaasProcessNodeTaskEntity> list);

    /**
     * 批量更新
     *
     * @param list
     * @param corpid
     */
    void updateBatch(List<PaasProcessNodeTaskEntity> list, String corpid);

    /**
     * 查询列表
     *
     * @param entity
     * @return java.util.List<ApplicationListVO>
     * @author wufeng
     * @date 2018/8/13 16:07
     * @descption
     */
    @Override
    List<PaasProcessNodeTaskEntityExt> findEntitys(Map<String, Object> entity);

    /**
     * 查询实体
     *
     * @param key    id
     * @param corpid 公司id
     * @return
     */
    PaasProcessNodeTaskEntity getByKey(Integer key, String corpid);

    /**
     * 查询列表数量
     *
     * @param entity
     * @return Integer
     * @author wufeng
     * @date 2018/8/13 16:07
     * @descption
     */
    @Override
    Integer getEntitysCount(Map<String, Object> entity);

    /**
     * 删除实体
     *
     * @param entity 实体
     * @return java.lang.Integer  mybatis操作结果，1：成功
     * @author wufeng
     * @date 2018/8/6 17:18
     * @descption
     */
    Integer delete(PaasProcessNodeTaskEntity entity);

    /**
     * 获取最新的那条流程任务数据
     *
     * @param map
     * @return PaasProcessNodeTaskEntityExt
     */
    PaasProcessNodeTaskEntityExt newProcessTask(Map<String, Object> map);

    /**
     * 获取各个流程的最新节点
     *
     * @param map
     * @return
     */
    List<PaasProcessNodeTaskEntityExt> getLatestNodeForList(Map<String, Object> map);

    /**
     * 根据任务id删除任务节点记录
     *
     * @param taskId
     * @param corpid
     */
    void deleteByTaskId(Long taskId, String corpid);

    /**
     * 根据任务列表删除任务节点记录
     *
     * @param nodeTaskList
     * @param corpid
     */
    void deleteBatch(List<PaasProcessNodeTaskEntityExt> nodeTaskList, String corpid);

    /**
     * 查询列表数量(distinct(task_id))
     *
     * @param entity
     * @return Integer
     * @author wufeng
     * @date 2018/8/13 16:07
     * @descption
     */
    Integer getTaskCount(Map<String, Object> entity);

    Integer readStartNode(PaasProcessNodeTaskEntity entity) throws XbbException;

    /**
     * 查询钉钉实例的任务
     * @param corpid
     * @param taskId
     * @return
     */
    List<String> getDingtalkProcessActivityId(String corpid, Integer taskId);

    /**
     * 特殊关联查询
     * @param map
     * @return
     */
    List<PaasProcessNodeTaskEntityExt> getJoinNodeForList(Map<String, Object> map);

    Integer getJoinNodeCount(Map<String, Object> map);

    /**
     * 根据表单id删除
     * @param formId
     * @param corpid
     * @return
     */
    Integer deleteByFormId(Long formId, String corpid);

    /**
     * 一键审批已读(审批抄送)
     * @param param
     */
    void readAllCcList(HashMap<String, Object> param);

    Integer getTaskCountLimit(Map<String, Object> entity);
}
